;#
;# L_extract_asm.S
;#
;# Extract from a 32 bit integer two 16 bit DPF.
;# 
;# Oded Rosen, 2011   
;#

	.text
	.globl L_Extract
	
	.arm
	
;#************************************************************************
;#
;#  FUNCTION: L_Extract 
;#
;#  PURPOSE:
;#     Extract from a 32 bit integer two 16 bit DPF.
;#
;#************************************************************************/

	;# inputs / outputs:
	L_32		.req r0
    hi			.req r1
    lo			.req r2
    
	;# temp values:
	h			.req r4
	l			.req r5
	t			.req r6
	c			.req r7
	

L_Extract:

		;# Stack current values:
		PUSH		{r4-r9}		;# stack
		
		ASR			h,L_32,#16
		STRH		h,[hi]
		ASR			l,L_32,#1
		MOV			c,#16384
		SMULBB 		t,h,c
		QDSUB		l,l,t
    	STRH		l,[lo]
	
		;# Unstack values and return:
		POP			{r4-r9}		;# unstack
		BX			lr				;# return
